/*  _________________________________________
   /                                      /_ \
  |             Player HUD               |/ \ |
  |                                      |___||
   \______________________________________\_/ |
       |                                      |
      /     Player H.U.D. Environment        /
     /     Written April, 2009,             /
    |     by Darrell Eastman.              |___
    |                                      |   |
     \______________________________________\_/
*/

////////////////////////// Client Attribute //////////////////////////
string		GamSte			= "Introduction";			//Current GameState
//int  		VisRng			= 12800;					//Visual Range
//int  		ActRng			= 6400;						//Active Range
//int  		IntRng			= 3200;						//Interactive Range
//string  	Nam				= "HondaDarrell";			//Name of Player
//string  	Cla				= "Pirate";					//Skill of Player
//string		Inv[][]			= {{""}, {""}};				//Player Iventory Key, Scroll
//string		WpnInf[][]		=							//Weapon Info Table
	//    Name|   Rate| Reload|    Max| Round| Damage|   Ammo|Report
	//        |    Ms.|    Ms.|       |      |    Hp.|     ID|Radius
	{{"Swd"   ,  "500",  "500",     "",    "",   "15",     "",    ""},
	{ "Stf"   , "1500", "1500",     "",    "",   "20",     "",    ""},
	{ "NunChk",  "150",  "150",     "",    "",    "5",     "",    ""},
	{ "ThrStr",  "500", "2000",   "25",   "5",    "5",    "1",    ""},
	{ "ThrKnf", "1000", "1500",   "15",   "2",   "10",    "2",    ""}};
string		EqpInf[][]		=							//Item Info Table
	//    Name| Reload|   Max|    Life|Damage|Report|   Ammo| ?
	//        |   /Ms.|      |     Ms.|   Hp.|Radius|     ID| ?
	{{"GrpHok",     "",    "",     "0", "000",    "",    "2",  "1"},
	{ "ZipLin",     "",    "",    "-1", "000",    "",    "3",  "3"},
	{ "LokPik",     "",    "",    "-1", "000",   "5",     "",   ""},
	{ "SmkBmb", ".025",   "5", "15000", "000", "100",     "",   ""},
	{ "GasBmb", ".025",   "5", "10000", "003",  "80",     "",   ""}};
int			Amm[]			=							//Weapon Select
	//Ammo|Round| Item| Current Weapon
	{ 1000, 0005, 1000, 00};
int			Eqp[]			= {2, 0};					//Equipment Select
float		Hth				= 100.0;					//Health Percentage
		
////////////////// Info HUD ///////////////////
ITexture	WpnIcn	=									//Weapon Icon Image
	driver.getTexture( "media/Weapon.tga" );
ITexture	ItmIcn	=									//Item Icon Image
	driver.getTexture( "media/Item.tga" );
ISceneNode	Tgt;										//Current Target
vector3df	TgtRot;										//Last Target Rotation
//ITexture	StsBar	=									//Status Bar Outline
//	driver.getTexture( "media/StatusBar.tga" )
//ITexture	Sts		=									//Status Bar Image					  
//	driver.getTexture( "media/Status.tga" )
float		ActTmr[3];									//Rate Timer Action Pri | Action Sec, Round Timer Action Pri
ITexture	TmrIcn	=									//Reload Overlay Image
	driver.getTexture( "media/Timer.tga" );
float		ActAcc[2];									//Accuracy Percentage, Action Pri | Action Sec
float		AphInd[3];									//Change Indication, Ammo Change | Items Change | Health Change

InfoHUD( Amm, Hth, WpnInf, EqpInf, AphInd, ActTmr, ActAcc, Eqp )
{	//Indicators
	int	T	= 1000;	//Fade in Milliseconds
	
	//Ammo Change Indication
	if( AphInd[0] > 0 )
		AphInd[0] -= 100 / ( T / LastFPS );
	else if( AphInd[0] < 0 )
		AphInd[0] = 0;

	//Round Change Indication
	if( AphInd[1] > 0 )
		AphInd[1] -= 100 / ( T / LastFPS );
	else if( AphInd[1] < 0 )
		AphInd[1] = 0;

	//Hth Change Indication
	if( AphInd[2] > 0 )
		AphInd[2] -= 100 / ( T / LastFPS );
	else if( AphInd[2] < 0 )
		AphInd[2] = 0;

	//Primary
	if( Amm[3] = 0 )
	//Draw Weapon
		driver->draw2DImageSegment( WpnIcn, position2di<s32>( 64, 640 ), 
			rect<s32>( Eqp[0] * 64, 0, 64 + ( Eqp[0] * 64 ), 64 ), null, 
			SColor( 255, 255, 255, 255 ), true );

	else if( Amm[3] = 1 )
	//Draw Item
		driver->draw2DImageSegment( ItmIcn, position2di<s32>( 64, 640 ), 
			rect<s32>( Eqp[1] * 64, 0, 64 + ( Eqp[1] * 64 ), 64 ), null, 
			SColor( 255, 255, 255, 255 ), true );

	//Primary Rounds
	if( Amm[3] = 0 )
	{
		//Draw Rounds Glow
		if( AphInd[1] > 0 )
			HUDGlow.Draw( Amm[1], 
				rect<s32>( 64, 640 - 16, 64 + ( 5 * 18 ), 640 + ( 28 / 2 )), 
				SColor( int(( 255 / 100 ) * AphInd[1] ), 0, 
								   255, 0 ));

		//Draw Rounds
		if( WpnInf[Eqp[0]][4] )
			HUDFont->Draw( Amm[1], 
				rect<s32>( 64, 640 - 16, 64 + ( 5 * 18 ), 640 + ( 28 / 2 )), 
				SColor( 255, int(( 127 / 100 ) * AphInd[1] ), 191 + int(( 64 / 100 ) * AphInd[1] ), int(( 127 / 100 ) * AphInd[1] )));
	}

	//* Incomplete, need to reposition text	//Draw Ammo
	if( Amm[3] = 0 && WpnInf[Eqp[0]][3] )
	{												   //Weapon, Capacity Not null		  
		if( AphInd[0] > 0 )
		{
			//Draw Ammo Glow
			HUDGlow.Draw( Amm[0], 
				rect<s32>( 64, 640, 64 + ( 5 * 18 ), 640 + ( 28 / 2 )), 
				SColor( int(( 255 / 100 ) * AphInd[0] ), 0, 255, 0 ));
			
			//Draw Ammo
			HUDFont.Draw( Amm[0], 
				rect<s32>( 64, 640, 64 + ( 5 * 18 ), 640 + ( 28 / 2 )), 
				SColor( 255, int(( 127 / 100 ) * AphInd[0] ), 191 + int(( 64 / 100 ) * AphInd[0] ), int(( 127 / 100 ) * AphInd[0] )));
		}
	}

	else
	if( Amm[3] = 1 && EqpInf[Eqp[1]][2] )
	{	
		//Item, Capacity Not null			  
		if( AphInd[0] > 0 )
		{
			//Draw Ammo Glow
			HUDGlow.Draw( Amm[2], 
				rect<s32>( 64, 640, 64 + ( 5 * 18 ), 640 + ( 28 / 2 )), 
				SColor( int(( 255 / 100 ) * AphInd[0] ), 0, 
								   255, 0 ));

			//Draw Ammo
			HUDFont.Draw( Amm[2], 
				rect<s32>( 64, 640, 64 + ( 5 * 18 ), 640 + ( 28 / 2 )), 
				SColor( 255, int(( 127 / 100 ) * AphInd[0] ), 191 + int(( 64 / 100 ) * AphInd[0] ), int(( 127 / 100 ) * AphInd[0] )));
		}
	}

	//Use Rate
	if( ActTmr[0] > 0 || ActTmr[1] > 0 )
	{
		//Weapon Rate
		if( ActTmr[0] > 0 )
			ActTmr[0] -= 1000 / LastFPS;	//Subtract 1 Millisecond		  

		//Item Rate
		if( ActTmr[1] > 0 )
			ActTmr[1] -= 1000 / LastFPS;	//Subtract 1 Millisecond		  
	}

	//Rounds
	if( ActTmr[2] > 0 && ActTmr[0] =< 0 )
	{
		//Draw Weapon Round Reload
		driver.draw2DImageSegment( TmrIcn, position2di<s32>( 64, 640 ), 
			rect<s32>( 0, 0, 64, 64 / Double( int( WpnInf[Eqp[Amm[3]]][2] ) * ActTmr[Amm[3] + 2] )), null, 
			SColor( 255, 255, 255, 255 ), true );

		//Weapon Reload
		if( ActTmr[2] > 0 )
			ActTmr[2] -= 1000 / LastFPS;	//Subtract 1 Millisecond
	}

	//Reload Rounds
	if( WpnInf[Eqp[0]][4] && Amm[0] > 0 && Amm[1] =< 0 && ActTmr[2] =< 0 )
	{
		ActTmr[2]	= int( WpnInf[Eqp[0]][2] );
		//Reload Rounds From Remaining Ammo
		Amm[1]		= int( WpnInf[Eqp[0]][4] );
		//Subtract Rounds From Ammo
		Amm[0]		-= int( WpnInf[Eqp[0]][4] );
		AphInd[0]	= 100;
		AphInd[1]	= 100;
	}
	else
	if( ActTmr[2] > 0 )
		ActTmr[2] -= float( 1000 / LastFPS );	//Subtract 1 Millisecond

	/*
	Accuracy Decay
	if( ActAcc[0] > 0 )
		ActAcc[0] -= Projectile.PrjInf[Eqp[0]][6]; 'Subtract Accuracy
	else
		ActAcc[0] = 0;
	
	if( ActAcc[1] > 0 )
		ActAcc[1] -= Projectile.PrjInf[Eqp[1]][6]; 'Subtract Accuracy
	else
		ActAcc[1] = 0;
	*/

	//Secondary
	//Draw Item
	driver.draw2DImageSegment( ItemIcon, position2di<s32>( 32, 704 ), 
		rect<s32>( 32 * Gadgets[1][0], 0, 32 + ( 32 * Gadgets[1][0] ), 32 ), 
		null,
		SColor( 255, 255, 255, 255 ), true );

	//Draw Gadgets
	if( AlphaIndication[1] > 0 )
		HUDGlow.Draw( Items[0][Items[1][0]], 
			rect<s32>( 64, 704, 64 + ( 5 * 18 ), 704 + ( 28 / 2 )), 
			SColor( int(( 255 / 100 ) * AlphaIndication[1] ), 0, 255, 0 ));
	HUDFont.Draw( Items[0][Items[1][0]], 
		rect<s32>( 64, 704, 64 + ( 5 * 18 ), 704 + ( 28 / 2 )), 
		SColor( 255, int(( 127 / 100 ) * AlphaIndication[1] ), 191 + int(( 64 / 100 ) * AlphaIndication[1] ), int(( 127 / 100 ) * AlphaIndication[1] )));
};